package com.hemh.handler;

import java.util.ArrayList;
import java.util.List;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@ConfigurationProperties(prefix = "config.path")  //读取配置文件
public class InterceptorConfig  implements WebMvcConfigurer {
	
	private List<String> excludeList = new ArrayList<String>();

    public void setExclude(List<String> excludeList) {
        this.excludeList = excludeList;
    }
    
    @Bean
    public ConfigPathInterceptor configPathInterceptor() {
        return new ConfigPathInterceptor();
    }
    
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
    		 registry.addInterceptor(configPathInterceptor())
    		 //.addPathPatterns("/**")/** 拦截所有 */
         .excludePathPatterns(excludeList)  ; /** 不拦截的url, 用于白名单 */  
    }


}
